package com.testDemo.hutool;

import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import org.junit.jupiter.api.Test;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.Date;

import static java.time.format.DateTimeFormatter.ISO_LOCAL_DATE;

/**
 * @author: zouren
 * @date: 2022/3/11
 * @description:
 */
public class DateUtilTest {
    @Test
    public void test(){

        String cur = DateUtil.today();
        System.out.println( cur);
        System.out.println(DateUtil.formatDate(DateUtil.offsetDay(  DateUtil.parse(cur), 30)));
    }

    @Test
    public void test1(){
        String  birthdate ="2024-06-21";
        DateTime parse = DateUtil.parse(birthdate);
        LocalDateTime localDateTime = LocalDateTimeUtil.parse(birthdate, DateTimeFormatter.ISO_LOCAL_DATE);
        long between = LocalDateTimeUtil.between(localDateTime, LocalDateTime.now(), ChronoUnit.DAYS);
        System.out.println(between);
    }
    @Test
    public void test2(){

        //当前时间
        Date oldTime = DateUtil.date(1730769747486L);
        System.out.println(  DateUtil.formatDateTime(oldTime));
        Date newTime = DateUtil.date(1730769744263L);
        System.out.println(  DateUtil.formatDateTime(newTime));


    }

}
